<?php
namespace Home\ Model;
use\ Frame\ Libs\ BaseModel;

final class UserModel extends BaseModel {
	//获取某用户捐书记录集
	public function getBookId( $uid ) {
		$sql = "SELECT donate_book_id FROM love_donate_book WHERE uid='$uid'";
		return $this->pdo->fetchAll( $sql );
	}

	//获取某用户捐书总数
	public function getBookSum( $id ) {
		$sql = "SELECT SUM(book_count) FROM love_donate_book_detail WHERE donate_book_id='$id'";
		return $this->pdo->fetchAll( $sql );
	}

	//获取某用户捐款总数
	public function getMoneySum( $uid ) {
		$sql = "SELECT SUM(money) FROM love_donate_money WHERE uid='$uid' AND status='1'";
		return $this->pdo->fetchAll( $sql );
	}

	//修改用户资料
	public function editProfile( $uid, $account, $name, $qq, $phone, $email, $sex ) {
		$sql = "UPDATE love_user SET account='$account',name='$name',email='$email',phone='$phone',sex='$sex',qq='$qq' WHERE uid='$uid'";
		return $this->pdo->exec( $sql );
	}

	//获得老密码
	public function getOldPwd( $uid ) {
		$sql = "SELECT password FROM love_user WHERE uid='$uid'";
		return $this->pdo->fetchOne( $sql );
	}

	//修改密码
	public function editPwd( $uid, $new ) {
		$sql = "UPDATE love_user SET password='$new' WHERE uid='$uid'";
		return $this->pdo->exec( $sql );
	}
}
?>